<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});

$api = app('Dingo\Api\Routing\Router');
$api->version('v1', function ($api) {
    $api->group([
        'namespace' => '\\App\\Api\\Controllers',
    ], function ($api) {
        $api->post('auth/login', 'AuthController@login'); //登录
        $api->post('upfile', 'AuthController@upfile'); //上传
        $api->post('uploads', 'IndexController@uploads'); // 文件上传
        // 公共接口
        $api->post('sms', 'AuthController@smsCode'); // 短信 验证码
        $api->post('reg/check', 'AuthController@checkReg'); //检测手机号是否注册
        $api->post('auth/reg', 'AuthController@reg');   //注册
        $api->post('user/interest', 'AuthController@userInterest'); //兴趣列表
        //商城接口
        $api->post('shop/banner', 'ShopController@banner'); //商城banner
        $api->post('shop/cate', 'ShopController@cate');     //商城分类
        $api->post('shop/products', 'ShopController@products'); //商城产品列表
        $api->post('shop/hot/products', 'ShopController@hotProducts'); //商城热门产品
        $api->post('products/detail', 'ShopController@detail'); //产品详情
        $api->post('products/sku', 'ShopController@productSku'); //产品详情
        $api->post('products/comments', 'ShopController@ProductComment'); //产品详情
        $api->post('/test','IndexController@test'); // 意见反馈
        $api->post('/vote','VoteController@vote'); // 投票活动
        $api->post('/vote/player','VoteController@votePlayer'); // 参赛者列表
        $api->post('/vote/info','VoteController@player'); //参赛着详情

        //获取登录用户的收货地址列表
        $api->group(['middleware' => ['refresh.token']], function ($api) {
            //购物车
            $api->post('cart/opt', 'CartController@add'); //添加
            $api->post('cart/index', 'CartController@index'); //列表
            $api->post('cart/stock', 'CartController@stock'); //库存判断
            $api->post('cart/del', 'CartController@del'); //删除
            //订单接口
            $api->post('order/check','OrderController@orderCheck'); //订单提交检查
            $api->post('order/add','OrderController@add'); //创建订单
            $api->post('order/close','OrderController@close'); //取消订单
            $api->post('order/index','OrderController@index'); //订单列表
            $api->post('order/detail','OrderController@detail'); //订单详情
            $api->post('order/receive','OrderController@receive'); //确认收货
            $api->post('order/tip','OrderController@tip'); //发送发货提醒
            $api->post('order/create/review','OrderController@createReview'); //订单评价
            $api->post('order/review','OrderController@viewReview'); //查看评价
            //用户接口
            $api->post('/user/money/log','UserController@moneyLog'); //资金明细
            $api->post('/user/score/log','UserController@scoreLog'); //积分明细
            $api->post('/user/optfans','UserController@optfuns'); //加关注取消关注
            $api->post('/user/follow','UserController@follow'); //关注列表
            $api->post('/user/fans','UserController@fans'); //粉丝列表
            $api->post('/user/addhistory','UserController@addhistory'); //添加浏览记录
            $api->post('/user/history','UserController@history'); //浏览记录列表
            $api->post('/user/level','UserController@level'); //会员等级列表
            $api->post('/user/paypass','UserController@paypass'); //会员等级列表
            $api->post('/user/findpaypss','UserController@findPaypss'); //找回密码
            $api->post('/user/live/apply','UserController@apply'); //找回密码
            $api->post('/user/info','UserController@info'); //用户中心-我的
            $api->post('/user/fav','UserController@favs'); //用户中心 收藏列表
            $api->post('/user/post','UserController@posts'); //用户中心 发布列表
            $api->post('/user/other','UserController@otherInfo'); //他人中心
            $api->post('/user/recommend','UserController@recommend'); // 推荐关注列表
            $api->post('/user/message','UserController@messages'); // 系统消息列表
            $api->post('/user/feedback','UserController@feedback'); // 意见反馈
            $api->post('/about','IndexController@about'); // 关于
            $api->post('/user/logout','UserController@logout'); // 退出

            //收货地址
            $api->get('user_address', 'UserAddressesController@index'); //地址列表
            $api->POST('user_address/detail', 'UserAddressesController@show');//地址详情
            $api->post('user_address', 'UserAddressesController@store'); //添加地址
            $api->post('user_address/update', 'UserAddressesController@update');//修改地址
            $api->post('user_address/del', 'UserAddressesController@destroy');//删除地址
            $api->post('user_address/default', 'UserAddressesController@setDefault');//设置默认地址
            //图文
            $api->post('/post/add','PostController@addArticle'); //发布图文
            $api->post('/post/index','PostController@index'); //图文列表
            $api->post('/post/up','PostController@upPost'); //图文列表
            $api->post('/post/add/commnet','PostController@addComment'); //图文评论
            $api->post('/post/commnet/up','PostController@addCommnetUp'); //评论点赞
            $api->post('/post/commnet/detail','PostController@detail'); //图文详情+评论列表
            $api->post('/post/addfav','PostController@addfav'); //添加收藏
            $api->post('/post/addtrans','PostController@addtrans'); //添加转发次数

            $api->post('/vote/user','VoteController@userVote'); // 投票活动
            $api->post('/vote/add/player','VoteController@addPlayer'); // 投票活动
        });
    });
});
